PR: Show whether notebook is dirty#504
Merged
jitseniesen merged 3 commits intospyder-ide:masterfrom Jan 22, 2026
Merged
Conversation
b0c899a to
685c287
Compare
Connect to the JavaScript signal emitted when a notebook becomes dirty or non-dirty. On receiving this signal, call alert() with a specially crafted message. Monitor alerts in Spyder and on receiving such an alert, emit a Qt signal. Using alert() as a side channel to communicate messages from JavaScript to Spyder is perhaps a bit hacky but it is simple and it works (as long as the alert message does not occur naturally). I expect that this mechanism is more widely applicable.
If a notebook is dirty (meaning that it has been changed since the last save), then add an asterix `*` to the file name in the title of the tab. This mirrors the behaviour of the editor.
Enable the File > Save menu item and the Save button in the Spyder toolbar only if there the current notebook is dirty (i.e., if there is something to save). Enable the Save All action only if any notebook is dirty. If the user triggers this action, then only save notebooks that are dirty.
685c287 to
780f034
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Monitor in Spyder whether a notebook has been edited after the last save. If that is the case, then put an
*(asterisk) after the filename in the title of the tab and enable the Save action. This brings the behaviour of the Notebook pane in line with the Editor pane.To implement this, we need a communication channel between the notebook JavaScript (which sends a signal if a notebook has unsaved changes) and Spyder itself. This PR uses the JavaScript
alert()function as the communication channel. If the message in the alert starts with a specific prefix (namely,:SpyderComm:), then this is interpreted as a message for Spyder and not for the user. This is perhaps a bit hacky (not using alert for what it is meant for), but it is easy to implement and I don't see a real disadvantage. The alternative would be to first open a channel to the notebook server (perhaps using Qt WebChannel) and then have the notebook server communicate with Spyder (perhaps using zeromq). I envisage that the new communication channel will have further uses.The video below shows the new behaviour implemented in this PR: after editing the notebook, an
*appears in the tab bar and the Save action is enabled; after saving, the*disappears and the Save action is disabled.dirty.mp4